<?php

class MAIDonation extends FTAObject {
		
		var $cmsDocument;
		
		function MAIDonation(){
			parent::__construct();
				
			global $db;	
			$this->cmsDocument = new CmsDocument($db);
		}
		
		function getDonations(){
			$this->cmsDocument->flush();
			$this->cmsDocument->setActiveDocuments();
			$this->cmsDocument->addDocumentType('docDonation');
			//$this->cmsDocument->sort("<<md.rank>>");
			$this->cmsDocument->setPageSize(null);
			$this->cmsDocument->setPageNumber(null);
			$this->cmsDocument->resetIterator();
			
			$allDocuments = $this->cmsDocument->getAllDocuments();
			
			if (!$allDocuments)
				$allDocuments = array();
				
			return $allDocuments;
			
		}
		
		function renderDonationsSelect(){
			$donations = $this->getDonations();
			if(is_null($donations))
				return;
				
					foreach($donations as $donation){
?>
	                 <option value="<?php echo $donation->documentcode; ?>"><?php echo $donation->title; ?></option>
<?
					}
														
		}
		
		
		
		
}


	function mai_getDonationsSelect() {
		ob_start();
		$maiObject = mai_getSharedDonationObject();	
		$maiObject->renderDonationsSelect();
		return ob_get_clean();			
	}

	function mai_getSharedDonationObject(){

		global $fta_;

		global $MAIDonationClass;
		
		if(!is_null($MAIDonationClass) && "MAIDonation" != $MAIDonationClass){
		} else {
			$MAIDonationClass = "MAIDonation";
		}
			
		if (!array_key_exists('maiDonation',$fta_)){
			$fta_->maiDonation = new  $MAIDonationClass();
		}
		return $fta_->maiDonation;
	}


?>